{extend name="base"/}
{block name="main"}
<div class="Hui-article">
    <article class="cl pd-20">
        <div class="n_tab_line">
            <a href="{:url('user/user_list')}" class="n_tab_list">微信会员</a>
            <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px;display: none;" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
            <div class="cl"></div>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <form class="Huiform" method="post" action="__CONF_SITE__admin/user/user_list" target="_self" style=" padding: 15px;">
                <div class="text-c">
                    日期范围：
                    <input type="text" onfocus="WdatePicker()" value="{$star_time}" name="star_time" class="input-text Wdate" style="width:120px;">
                    -
                    <input type="text" onfocus="WdatePicker()" value="{$end_time}" name="end_time" class="input-text Wdate" style="width:120px;">
                    <input type="text" class="input-text" value="{$search_text}" style="width:250px" placeholder="输入会员昵称"  name="search_text">
                    <button type="submit" class="btn btn-search radius"  name=""><i class="Hui-iconfont">&#xe665;</i> 搜会员</button>
                </div>
            </form>
        </div>
        <table class="table table-border table-bordered table-bg">
            <thead>
            <!--
                        <tr>
                            <th scope="col" colspan="9">微信会员</th>
                        </tr>
            -->
            <tr class="text-c">
                <th>排序</th>
                <th>头像</th>
                <th>昵称</th>
                <th>总累计积分</th>
                <th>当前可用积分</th>
                <th>积分更改</th>
                <th>会员等级</th>
                <th>积分抵扣比例</th>
                <th>注册时间</th>
            </tr>
            </thead>
            <tbody>
            {volist name="user_list" id="vo"  key="k"}
            <tr class="text-c">
                <td>{$num*20-20+$k}</td>
                <td>
                    <img src="{$vo.user_headimg}" width="50px" class="round">
                </td>
                <td>{$vo['nick_name']}</td>
                <th>{$vo['consume']}</th>
                <th>{$vo['integral']}</th>
                <th>
                    <i class="Hui-iconfont Hui-iconfont-shuru"
                       style="cursor: pointer;"
                       onclick="edit_integral('积分更改','__CONF_SITE__admin/user/edit_integral&id={$vo.uid}','650px','400px');">编辑</i>
                </th>
                <th>{$vo['level_name']|default="无"}</th>
                <td><input type="number" id="input" class="input-text" onblur="change_dec(this.value,'{$vo.uid}')" style="width: 100px;" value="{$vo['deduction']}">%</td>
                <td>{$vo['reg_time']|date='Y-m-d H:i:s',###}</td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </article>
    <div class="n_page_no">
        {$page}
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="/public/js/jquery-2.1.1.js"></script>
<script type="text/javascript" src="/public/static/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript">
function change_dec(a,uid){
    if(a>=100){
        layer.msg('积分抵扣比例不超过100%', {icon: 2, time: 1000});
        return false;
    }else if(a<0){
        layer.msg('积分抵扣比例不小于0', {icon: 2, time: 1000});
        return false;
    }
    $.ajax({
        type : "post",
        url : "{:url('user/change_deduction')}",
        data : {
            "uid" : uid,
            "deduction":a
        },
        success : function(data) {
            if (data > 0) {
                layer.msg('操作成功!',{icon:1,time:1000});
            }else{
                layer.msg('操作失败!', {icon: 2, time: 1000});
            }
        }
    })
}
    /*
     参数解释：
     title	标题
     url		请求的url
     id		需要操作的数据id
     w		弹出层宽度（缺省调默认值）
     h		弹出层高度（缺省调默认值）
     */
    /*会员-删除*/
    function user_del(obj,uid){
        layer.confirm('确认要删除吗？',function(index){
            //此处请求后台程序
            //后台处理
            $.ajax({
                type : "post",
                url : "{:url('user/deleteUserAjax')}",
                data : {
                    "uid" : uid,
                },
                success : function(data) {
                    if (data > 0) {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }else{
                        layer.msg('删除失败!', {icon: 2, time: 1000});
                    }
                }
            })
        });
    }
    //积分更改
    function edit_integral(title, url, w, h) {
        layer.open({
            type: 2,
            area: [w, h],
            fix: false, //不固定
            maxmin: true,
            shade: 0.4,
            title: title,
            content: url,
            scrollbar: false
        });
    }
</script>
{/block}